<template>
  <div class="flex justify-start">
    <vxe-pulldown ref="pulldownRef" destroy-on-close transfer>
      <template #default>
        <div class="item-panel padding-sm radius bg-orange light margin-lr-sm cursor" :class="itemStep.isActive ? 'active text-white text-blod' : ''" @dblclick="itemDblClick">
          <div class="flex justify-start">
            <div class="center-box" @click="itemClick">
              <div class="item-top">
                <div class="item-title text-cut">
                  <span class="text-shadow">{{ `${itemStep.nodeDictName}` }}</span>
                </div>
              </div>
              <div class="item-center text-shadow">
                <span class="text-xs">2024.01.01</span>
                <span>~</span>
                <span class="text-xs">2024.02.01</span>
              </div>
              <div class="item-bottom">
                <span class="solids-bottom line-black"></span>
              </div>
            </div>
            <div class="right-box">
              <div class="status-icon-box">
                <div class="item-icon">
                  <span class="vxe-icon-square-plus-fill" @click="addItemClick"></span>
                  <span class="vxe-icon-menu margin-left-xs" @click="itemDblClick"></span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </template>
      <template #dropdown>
        <div class="my-dropdown3">
          <vxe-table border="inner" ref="tableRef" :column-config="{resizable: true}" :row-config="{isCurrent:true}" :tree-config="{transform: true, rowField: 'id', parentField: 'parentId'}" :data="tableData" @toggle-tree-expand="toggleExpandChangeEvent">
            <vxe-column field="name" title="分纯节点" tree-node></vxe-column>
          </vxe-table>
        </div>
      </template>
    </vxe-pulldown>

    <div class="padding-sm radius arrow-font" v-if="isShowNexrArrow">
      <el-icon>
        <Right />
      </el-icon>
    </div>
  </div>
</template>

<script setup lang="ts">
import { computed, reactive, getCurrentInstance, ref } from 'vue';
import FlowStepCompItem from './FlowStepItemComp.vue';

let { proxy }: any = getCurrentInstance();
const pulldownRef = ref(null);
const props = defineProps({
  itemStep: {},
  isShowNexrArrow: { type: Boolean, default: true }
});

let tableData = ref([
  { id: 10000, parentId: null, name: '分纯节点1', type: 'mp3', size: 1024, date: '2020-08-01' },
  { id: 10050, parentId: null, name: '分纯节点2', type: 'mp4', size: 0, date: '2021-04-01' },
  { id: 24300, parentId: 10050, name: '分纯节点2-1子步骤', type: 'avi', size: 1024, date: '2020-03-01' },
  { id: 20045, parentId: 24300, name: '分纯节点2-1子步骤三级步骤1', type: 'html', size: 600, date: '2021-04-01' },
  { id: 10053, parentId: 24300, name: '分纯节点2-1子步骤三级步骤2', type: 'avi', size: 0, date: '2021-04-01' },
  { id: 23666, parentId: null, name: '分纯节点3', type: 'xlsx', size: 2048, date: '2020-11-01' },
  { id: 23677, parentId: 23666, name: '分纯节点3-1子步骤', type: 'js', size: 1024, date: '2021-06-01' },
  { id: 23671, parentId: 23677, name: '分纯节点3-1子步骤三级步骤1', type: 'js', size: 1024, date: '2021-06-01' },
  { id: 23672, parentId: 23677, name: '分纯节点3-1子步骤三级步骤2', type: 'js', size: 1024, date: '2021-06-01' },
  { id: 23688, parentId: 23666, name: '分纯节点5', type: 'js', size: 1024, date: '2021-06-01' },
  { id: 24555, parentId: null, name: '分纯节点4', type: 'avi', size: 224, date: '2020-10-01' },
]);

/**节点选中 */
const itemClick = () => {
  proxy.$emit('itemClick', props.itemStep);
};
/**节点双击事件 */
function itemDblClick() {
  proxy.$emit('itemClick', props.itemStep);
  pulldownRef.value?.togglePanel();
}
/**在此之后添加节点 */
const addItemClick = () => {
  proxy.$emit('addItemClick', props.itemStep);
}

function toggleExpandChangeEvent(){
  
}
</script>

<style scoped lang="scss">
$primary-1: var(--primaryColor1);
$primary-2: var(--primaryColor2);
$backgroundColor: var(--backgroundColor);

$transition: all 500ms ease;

.item-panel {
  width: 140px !important;
  height: 30px;
  white-space: break-spaces;
  align-content: center;
  border-radius: 5px;
  text-align: center;
  vertical-align: middle;
}

.status-icon-box {
  display: flex;
  font-size: 1.5em !important;
  font-weight: 800 !important;
  align-items: center;
  justify-content: center;
  padding: 0px 10px;
}

.arrow-font {
  display: flex;
  font-size: 2em !important;
  font-weight: 800 !important;
  align-items: center;
  justify-content: center;
  color: #ff9900;
}

.cursor {
  cursor: pointer;
}

.icon-success {
  position: absolute;
  opacity: 0;
  transform: scale(0);
  width: 24px;
  transition: $transition;
}

.active {
  background-color: $background-color-green;
  color: white;
}

.my-dropdown3 {
  width: 400px;
  background-color: #fff;
  box-shadow: 0 0 6px 2px rgba(0, 0, 0, 0.1);
  border-radius: 8px;
}
</style>
